package com.example.easyexceldemo.util;

import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class ResponseResult<T> {
	// 返回状态码
	private Integer code = 0;
	// 返回消息
	private String message = "";
	// 返回对象
	private T data;

	/**
	 * 成功
	 * @param <T>
	 * @return
	 */
	public static <T> ResponseResult<T> success(){
		return new ResponseResult<T>();
	}

	/**
	 * 成功
	 * @param <T>
	 * @param data
	 * @return
	 */
	public static <T> ResponseResult<T> success(T data){
		return new ResponseResult<T>().setData(data);
	}
	
	/**
	 * 失败
	 * @param <T>
	 * @param code
	 * @param message
	 * @return
	 */
	public static <T> ResponseResult<T> failure(int code, String message){
		return new ResponseResult<T>().setCode(code).setMessage(message);
	}
	
	/**
	 * 失败
	 * @param <T>
	 * @param code
	 * @param message
	 * @param data
	 * @return
	 */
	public static <T> ResponseResult<T> failure(int code, String message,T data){
		return new ResponseResult<T>().setCode(code).setMessage(message).setData(data);
	}


}
